草庐IT

Java HttpURLConnection - 带 Cookie 的 POST

全部标签

c# - 如何在 Web API 授权属性中获取请求 cookie?

在.NET中有两个AuthorizeAttribute类。一个在System.Web.Http命名空间中定义:namespaceSystem.Web.Http{//Summary://Specifiestheauthorizationfilterthatverifiestherequest'sSystem.Security.Principal.IPrincipal.[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method,Inherited=true,AllowMultiple=true)]publicclassAut

c# - Asp.net 身份过期 session Cookie

我们正在使用MVC5.2和ASP.NETIdentity使用表单例份验证屏幕(用户和密码组合)进行身份验证的框架,并且使用cookie保留身份。我在身份框架的启动方法中进行了配置,将身份验证cookie的到期时间设置为30天,当用户选择“记住我”(IsPersistent=true)时,这很好用。当IsPersistent=false(用户选择不选择“记住我”)时,默认创建sessioncookie。此sessioncookie在InternetExplorer和FireFox中运行良好,当浏览器关闭时,cookie将丢失。在Chrome和Safari(可能还有其他浏览器)中,有一些选

c# - AngularJS 与 Asp.net Web API : $http post returning XMLHttpRequest cannot load: Response for preflight has invalid HTTP status code 405

当尝试使用$http将jsonPOST到Asp.netwebAPI服务器时,它返回以下错误XMLHttpRequestcannotloadhttp://localhost:62158/api/video/add.ResponseforpreflighthasinvalidHTTPstatuscode405但是从$.ajax发出相同的请求是工作文件。$HTTP代码$http.post(url,data,config).success(function(data,status,headers,config){defered.resolve(data);}).error(function(d

c# - ASP.NET Core 2.0 预览版 1 : How to set up Cookie Authentication with custom login path

在ASP.NETCore2.0中,.UseAuthentication()中间件有一个重大更改,不再允许oldsyntaxmentionedhere去工作。新版本似乎在addAuthentication中处理配置,但我无法在任何地方找到任何关于如何更改指定自定义登录和注销url的旧代码的详细信息。services.AddAuthentication(o=>{//WherecanIspecifythis?????varopt=newCookieAuthenticationOptions(){LoginPath="/api/login",LogoutPath="/api/logout",}

c# - 如何在 CefSharp 中保存 cookie

我是CefSharp的新手。上周我在C#中使用CefSharp构建了我的第一个小程序。这是一个分屏程序。在一次拆分中,我加载了Tweetdeck。它工作正常,但Tweetdeck不存储cookie。每次启动程序时,我都必须登录。有没有办法保存cookies?varbrowser1=newCefSharp.WinForms.ChromiumWebBrowser("https://tweetdeck.twitter.com/"){Dock=DockStyle.Fill,};splitContainer1.Panel1.Controls.Add(browser1);

c# - Windows Phone 应用程序不发送 Cookie,但在 Windows 8 应用程序中使用相同的代码发送 Cookie

我有一个使用HttpWebRequest/HttpWebResponse发出GET和POST请求的基本类。我使用我的类登录API,然后请求数据。在Windows8“Metro”应用程序中,它完全按预期工作。在WindowsPhone8应用程序上,登录似乎成功,但在随后的数据请求中,没有发送任何cookie,服务器响应就好像客户端未登录一样。这是类,在Windows8应用程序和WindowsPhone应用程序中使用了完全相同的代码:classClass1{CookieContainercookieJar=newCookieContainer();CookieCollectionrespo

c# - .Net Core 中的 .AspNetCore.Antiforgery.xxxxxxx cookie 是什么?

我试图在.NetCore中使用ValidateAntiForgeryToken,但我得到的是.AspNetCore.Antiforgery.xxxxxxxcookie丢失。这个.AspNetCore.Antiforgery.xxxxxxxcookie是什么? 最佳答案 ASP.NETCore查找此cookie以找到X-CSRFtoken。TheValidateAntiForgeryTokenisanactionfilterthatcanbeappliedtoanindividualaction,acontroller,orgloba

c# - HttpClient 不保存 Cookie

我正在使用新的HttpClient来处理我的项目的网上冲浪需求;但是,尽管设置正确,但HttpClient不会将cookie保存到Cookie容器中,它始终为EMPTY。代码privateCookieContainer_cookieContainer=newCookieContainer();privateHttpClientHttpClient{get;set;}privateHttpClientHandlerHttpClientHandler{get;set;}publicInitialize(){HttpClientHandler=newHttpClientHandler{All

c# - 无法在 ASP.NET 中更新 cookie

我快疯了。我可以写入cookie,然后再读取它。但在某些时候,我想更新它所持有的值(value)。每当我再次获得cookie时,我都会得到初始值,而不是更新后的值。下面是我用于写入/更新和读取cookie的代码。privatestaticHttpCookieWriteCookie(GuidsiteId,stringsiteName){varcookie=HttpContext.Current.Request.Cookies.Get("UserSettings");if(cookie!=null){cookie.Value=EncryptObject(newUserSettingsMod

c# - 如何从 ASP.NET Web API ValueProvider 中的 HTTP POST 请求检索正文值?

我想发送一个HTTPPOST请求,其正文包含构成一篇简单博客文章的信息,没什么特别的。我读过here当您想在WebAPI中绑定(bind)复杂类型(即不是string、int等的类型)时,一个好的方法是创建自定义模型绑定(bind)器。我有一个自定义模型绑定(bind)器(BlogPostModelBinder),它又使用自定义值提供程序(BlogPostValueProvider)。我不明白的是,我应该如何以及在何处能够从BlogPostValueProvider中的请求正文中检索数据?在模型Binder中,这是我认为的正确方法,例如检索标题。publicboolBindModel(